package cn.com.shinho.hg.auth.modular.service.impl;

import cn.com.shinho.hg.auth.modular.entity.TbSysOperate;
import cn.com.shinho.hg.auth.modular.entity.TbSysUserRole;
import cn.com.shinho.hg.auth.modular.mapper.TbSysUserRoleMapper;
import cn.com.shinho.hg.auth.modular.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 用户权限吧 服务实现类
 * </p>
 *
 * @author Mr.Ye
 * @since 2018-07-09
 */
@Service
public class SysRoleServiceImpl implements ISysRoleService {

    @Autowired
    TbSysUserRoleMapper sysUserRoleMapper;

    @Override
    public List<Long> getUserRoleByUserId(Long userId) {
        TbSysUserRole role = new TbSysUserRole();
        role.setUserid(userId.intValue());
        List<TbSysUserRole> sysUserRoles = sysUserRoleMapper.select(role);
        List<Long> userIdList = new ArrayList<>();
        sysUserRoles.forEach(p->userIdList.add(p.getUrid().longValue()));
        return  userIdList;
    }

    @Override
    public List<TbSysOperate> getSysPermisionsByRole(Long roleId) {
        return null;
    }
}
